package com.protocolterminal.AFN.entity;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.protocolterminal.function.FrameFunction;

public class AFN0CF129 implements Interface_Data {

	@Override
	public String frametolist(String frame) throws Exception {
		List<String> list = new ArrayList<>();

		FrameFunction frameFunction = new FrameFunction();
		// 抄表时间
		list.add(frameFunction.Reverse(frame.substring(0, 10)));

		Pattern pattern = Pattern.compile("[0-9]*");
		Matcher isNum = pattern.matcher(list.get(0));
		if (!isNum.matches()) {
			return null;
		}

		int i = Integer.valueOf(frame.substring(10, 12), 16);

		DecimalFormat df = new DecimalFormat("######0.00");
		for (int j = 0; j < i + 1; j++) {
			String svalue = frameFunction.Reverse(frame.substring(12 + 10 * j, 22 + 10 * j));
			svalue = svalue.replace("EE", "00");
			Double value = Double.valueOf(svalue) / 10000;
			list.add(df.format(value));
		}

		String data = "";
		for (String string : list) {
			data += string + "-";
		}

		return data.substring(0, data.length() - 1);
	}

	@Override
	public String listtoframe(List<String> datalist) throws Exception {

		return "";
	}

}
